<template>
	<view>
		<view class="steps">
			<uni-steps :options="list1" active-color="#007AFF"  :active="active" />
			<view>
				<view>
					<form @submit="formSubmit" @reset="formReset">
						<view class="uni-form-item uni-column">
							<view class="title">学员编号</view>
							<view>
								<input style="" class="uni-input" name="studentNumber" v-model="student.studentNumber"
									placeholder="请输入学员编号" />
							</view>
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">真实姓名</view>
							<view>
								<input class="uni-input" name="studentName" placeholder="请输入真实姓名"/>
							</view>
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">手机号码</view>
							<view>
								<input class="uni-input" name="studentPhone" placeholder="请输入手机号码" />
							</view>
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">身份证号</view>
							<view>
								<input class="uni-input" name="studentIdNumber" placeholder="请输入身份证号" />
							</view>
						</view>
						<view class="uni-form-item uni-column" style="display: flex;">
							<view class="title" style="margin-top:-10px;">性别</view>
							<view>
								<radio-group name="studentSex" style="margin-left: 10px;">
									<label>
										<radio value="男" /><text>男</text>
									</label>
									<label>
										<radio value="女" /><text>女</text>
									</label>
								</radio-group>
							</view>
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">出生日期</view>
							<view>
								<!-- <uni-datetime-picker v-model="vModelDatetime" start="2010-6-10 08:30:30" end="2021-6-10 08:30:30"></uni-datetime-picker> -->
								<uni-datetime-picker type="date" :value="date" start="2020-6-15" end="2025-6-15" @change="dateChange"></uni-datetime-picker>
							</view>
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">联系地址</view>
							<view>
								<input class="uni-input" name="studentAddress" placeholder="请输入联系地址" />
							</view>
						</view>
						<view class="uni-form-item uni-column">
							<view class="title">备注</view>
							<view>
								<input class="uni-input" name="note" placeholder="请输入备注" />
							</view>
						</view>
						<input name="birthday" type="hidden" disabled="true" />
						<view class="uni-btn-v">
							<button form-type="submit" class="button-green" @click="change()">保存</button>
						</view>
					</form>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>
<script>
	import {parseTime} from"../../../api/ruoyi.js"
	export default {
		data() {
			return {
				date:"",
				student:{
					studentNumber:"",
					studentName:"",
					studentSex:"",
					studentBirthday:"",
					studentPhone:"",
					studentIdNumber:"",
					studentAddress:"",
					note:"",
					concatRelation:"",
					concatName:"",
					concatPhone:""
				},
				active: 0,
				list1: [{
						title: '学员信息'
					},
					{
						title: '补充信息'
					},
					{
						title: '报名/试听'
					},
				]
			}
		},
		onLoad() {
			this.getStudentNumberByDate()
		},
		methods: {
			change(){ //改变步骤条
				if (this.active < this.list1.length - 1) {
					this.active += 1
					if (this.active = 2) {
						uni.navigateTo({
							url: "./registered2?obj="+encodeURIComponent(JSON.stringify(this.student))
						})
					}
				}
			},
			dateChange(time){
				this.student.studentBirthday = time//获得生日
				console.log(this.student.studentBirthday,"学生生日选择后获取")
			},
			getStudentNumberByDate(){//生成学生编号
				let time = parseTime(new Date(), '{y}{m}{d}{h}{i}{s}');
				this.student.studentNumber = "ST" + time;
				console.log()
			},
			formSubmit: function(e) {
				console.log('form发生了submit事件，携带数据为：' + JSON.stringify(e.detail.value))
				var formdata = e.detail.value//表单对象
				this.student.studentName = formdata.studentName
				this.student.studentPhone = formdata.studentPhone
				this.student.studentIdNumber = formdata.studentIdNumber
				this.student.studentSex = formdata.studentSex
				this.student.studentAddress = formdata.studentAddress
				this.student.note = formdata.note
				console.log(this.student,"学生对象")
			},
			formReset: function(e) {
				console.log('清空数据')
			}
		}
	}
</script>

<style scoped>
	.steps {
		margin-top: 18px;

	}

	.uni-form-item .title {
		padding: 20rpx 0;
		margin-left: 40px;
	}

	.uni-column {
		display: flex;
		margin-top: 15px;
	}
	input{
		margin:10px 10px
	}

</style>
